
import java.util.Comparator;
import java.util.PriorityQueue;

// ⽤⼾⾃⼰定义的⽐较器：直接实现Comparator接⼝，然后重写该接⼝中的compare⽅法即可
class MaxC implements Comparator<Integer> {
    @Override
    public int compare(Integer o1, Integer o2) {
        return o2-o1;
    }
}

public class Test {

    public static void main(String[] args) {

        PriorityQueue<Integer> p1 = new PriorityQueue<>(new MaxC());
        p1.offer(6);
        p1.offer(10);
        p1.offer(5);
        p1.offer(8);
        System.out.println(p1.peek());

    }
}
